package com.tongcheng.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.tongcheng.ResultDate;

import com.tongcheng.commons.Contants;
import com.tongcheng.feign.ActivityseviceFeign;
import com.tongcheng.feign.CouponsseviceFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
@Service
public class Couponssevice implements CouponsseviceFeign {
    @Autowired(required = false)
    private CouponsseviceFeign couponsseviceFeign;
    @HystrixCommand(fallbackMethod = "checkError1")
    public ResultDate addCoupons(Map map) {
        return couponsseviceFeign.addCoupons(map);
    }
    @HystrixCommand(fallbackMethod = "checkError2")
    public ResultDate queryCouponsByactid(Integer activity_id){
        return couponsseviceFeign.queryCouponsByactid(activity_id);
    }
    @HystrixCommand(fallbackMethod = "checkError3")
    public ResultDate delCoupons(Integer coupons_id){
        return couponsseviceFeign.delCoupons(coupons_id);
    }
    @HystrixCommand(fallbackMethod = "checkError4")
    public  ResultDate queryCouponsByuserid(Integer userId){
        return couponsseviceFeign.queryCouponsByuserid(userId);

    }
    @HystrixCommand(fallbackMethod = "checkError5")
    public ResultDate updateCoupons(Map map) {
        return couponsseviceFeign.updateCoupons(map);
    }

    @HystrixCommand(fallbackMethod = "checkError6")
    public ResultDate queryAllCoupons() {
        return couponsseviceFeign.queryAllCoupons();
    }

    public ResultDate checkError1(Map map) {
        ResultDate resultDate=new ResultDate();
        resultDate.setCode(Contants.FAILURE);
        resultDate.setMsg("系统异常");
        return resultDate;
    }

    public ResultDate checkError2(Integer activity_id) {
        ResultDate resultDate=new ResultDate();
        resultDate.setCode(Contants.FAILURE);
        resultDate.setMsg("系统异常");
        return resultDate;
    }
    public ResultDate checkError3(Integer coupons_id) {
        ResultDate resultDate=new ResultDate();
        resultDate.setCode(Contants.FAILURE);
        resultDate.setMsg("系统异常");
        return resultDate;
    }
    public ResultDate checkError4(Integer userId) {
        ResultDate resultDate=new ResultDate();
        resultDate.setCode(Contants.FAILURE);
        resultDate.setMsg("系统异常");
        return resultDate;
    }
    public ResultDate checkError5(Map map) {
        ResultDate resultDate=new ResultDate();
        resultDate.setCode(Contants.FAILURE);
        resultDate.setMsg("系统异常");
        return resultDate;
    }
    public ResultDate checkError6() {
        ResultDate resultDate=new ResultDate();
        resultDate.setCode(Contants.FAILURE);
        resultDate.setMsg("系统异常");
        return resultDate;
    }

}
